package com.mlog.njyjy.ndop.msg.relay.support;

import com.samskivert.mustache.Mustache;

import java.io.StringWriter;
import java.util.Map;

/**
 * 渲染文本
 *
 * @author zyz
 * @version v1.0, 2020/8/3
 */
public class MustacheEngine {

    private static Mustache.Compiler compiler = Mustache.compiler();

    public static String renderText(String tpl, Map<String, String> data) {
        StringWriter writer = new StringWriter(tpl.length());
        compiler.compile(tpl).execute(data, writer);
        writer.flush();
        return writer.toString();
    }
}
